<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$USER = getAccountUserObject();
	$history_id = $this->uri->segment(5,0);
	 
	$PAYMENT_HIS = $this->payment_history->init('id',$history_id);
	
	if(!$PAYMENT_HIS OR $PAYMENT_HIS->user_id != $USER->getId() ){
		show_404();
	}
	$payment_log_array = array_filter(explode(',',$PAYMENT_HIS->getPaymentIds()));
	$totalPeriodDiscount = $totalVolumnDiscount = 0;
?>

<div id="content-left">
	<div id="personal-tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
			<!-- content -->	
				
				<div class="dashboard-info-wrapper">
					<div class="select-box">
							<table width="100%">
								<thead>
									<th><?php echo language_translate('services_page_table_head_servicename');?></th>
									<th><?php echo language_translate('services_page_table_head_details');?></th>
									<th><?php echo language_translate('services_page_table_head_period');?></th>
									<th style="text-align:right;"><?php echo language_translate('services_page_table_head_priceeuro');?></th>
								</thead>
								<tbody>
									<?php foreach($payment_log_array as $item):?>
										<?php 
											$PAY_LOG = $this->payment_log_entity->init('id',$item);
										?>
										
										<?php if($PAY_LOG->getServiceType() == 'SUBS'): ?>
											<tr>
												<?php 
													$subs_array = getSubcriptionData_ioc($PAY_LOG->type_id);
													$totalPeriodDiscount += $PAY_LOG->discount_period_price;
													$totalVolumnDiscount += $PAY_LOG->discount_volumn_price;
												?>
												<td><?php echo language_translate('services_page_subscription');?></td>
												<td><?php echo $subs_array[0];?></td>
												<td><?php echo $PAY_LOG->period;?></td>
												<td style="text-align:right;"><?php echo euroCurrencyFormat(number_format( $PAY_LOG->payment_price, 2 ));?></td>
											</tr>
										<?php endif; ?>
										
										<?php if($PAY_LOG->getServiceType() == 'PLACE'): ?>
											<tr>
												<?php 
													$placeInfo = getPlaceListDataInfoById($PAY_LOG->type_id);
													$desc = $placeInfo['country'];
													if($placeInfo['state']){
														$desc .= "/".$placeInfo['state'];
													}	
													if($placeInfo['province']){
														$desc .= "/".$placeInfo['province'];
													}
													if($placeInfo['city']){
														$desc .= "/".$placeInfo['city'];
													}
													$totalPeriodDiscount += $PAY_LOG->discount_period_price;
													$totalVolumnDiscount += $PAY_LOG->discount_volumn_price;
												?>
												<td><?php echo language_translate('services_page_where_do_you_work');?></td>
												<td><?php echo $desc;?></td>
												<td><?php echo $PAY_LOG->period;?></td>
												<td style="text-align:right;"><?php echo euroCurrencyFormat(number_format( $PAY_LOG->payment_price, 2 ));?></td>
											</tr>
										<?php endif; ?>
										
										<?php if($PAY_LOG->getServiceType() == 'PACK'): ?>
											<tr>
												<?php 
													$pack_array = getPackListData_ioc($PAY_LOG->type_id);
													$totalPeriodDiscount += $PAY_LOG->discount_period_price;
													$totalVolumnDiscount += $PAY_LOG->discount_volumn_price;
												?>
												<td><?php echo language_translate('services_page_add_a_pack');?></td>
												<td><?php echo $pack_array[0];?></td>
												<td><?php echo $PAY_LOG->period;?></td>
												<td style="text-align:right;"><?php echo euroCurrencyFormat(number_format( $PAY_LOG->payment_price, 2 ));?></td>
											</tr>
										<?php endif; ?>
										
										<?php if($PAY_LOG->getServiceType() == 'PRI'): ?>
											<tr>
												<?php 
													$pri_array = getPriorityData_ioc($PAY_LOG->type_id);
													$totalPeriodDiscount += $PAY_LOG->discount_period_price;
													$totalVolumnDiscount += $PAY_LOG->discount_volumn_price;
												?>
												<td><?php echo language_translate('services_page_priority');?></td>
												<td><?php echo $pri_array[0];?></td>
												<td><?php echo $PAY_LOG->period;?></td>
												<td style="text-align:right;"><?php echo euroCurrencyFormat(number_format( $PAY_LOG->payment_price, 2));?></td>
											</tr>
										<?php endif; ?>
										
									<?php endforeach; ?>
								</tbody>
							</table>
					</div>
				</div>	
				<div class="clear"></div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_your_discount_info');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<span id="promotion-info">
								<?php echo $PAYMENT_HIS->volumn_discount;?>
								<?php 
									if($PAYMENT_HIS->volumn_discount_unit == 'PERCENT'){
										echo '%';
									}else{
										echo '&euro;';
									}
								?>
							 </span>
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="clear"></div>
				
			<div class="dashboard-info-wrapper">
				<div class="dashboard-info-left"><span><?php echo language_translate('contract_volumn_discount');?></span></div>
				<div class="dashboard-info-right">
					<div class="select-box">
						<?php echo euroCurrencyFormat(number_format($totalVolumnDiscount,2));?> &euro;
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="dashboard-info-wrapper">
				<div class="dashboard-info-left"><span><?php echo language_translate('services_page_total_period_discount');?></span></div>
				<div class="dashboard-info-right">
					<div class="select-box">
						<?php echo euroCurrencyFormat(number_format($totalPeriodDiscount,2));?> &euro;
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="dashboard-info-wrapper">
				<div class="dashboard-info-left"><span><?php echo language_translate('services_page_net_amount');?></span></div>
				<div class="dashboard-info-right">
					<div class="select-box">
						<?php echo euroCurrencyFormat(number_format( $PAYMENT_HIS->net_amount, 2 ));?> &euro;
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="dashboard-info-wrapper">
				<div class="dashboard-info-left"><span><?php echo language_translate('contract_start_date');?></span></div>
				<div class="dashboard-info-right">
					<div class="select-box">
						<?php echo sysDateFormat( $PAYMENT_HIS->start_date ,DATE_FORMAT );?>
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="dashboard-info-wrapper">
				<div class="dashboard-info-left"><span><?php echo language_translate('contract_to_date');?></span></div>
				<div class="dashboard-info-right">
					<div class="select-box">
						<?php echo sysDateFormat( $PAYMENT_HIS->end_date ,DATE_FORMAT );?>
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="dashboard-info-wrapper">
				<div class="dashboard-info-left"><span><?php echo language_translate('services_page_escorts_apply_number');?></span></div>
				<div class="dashboard-info-right">
					<div class="select-box" id="apply_number">
						<?php echo $PAYMENT_HIS->escorts_apply_number ;?> 
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="clear"></div>
		</div>
	</div>
</div>	


<?php $this->load->view('agent/right_nav'); ?>	